<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
			
			function fun(clon1 , clon2){//输入要交换的标签的id
					var a1= document.getElementById(clon1);
					var clona1 = a1.cloneNode(true);
					var s1 = a1.parentNode;
					
					var a2= document.getElementById(clon2);
					var clona2 = a2.cloneNode(true);
					var s2 = a2.parentNode;
					
					s1.replaceChild(clona2 , a1);
					s2.replaceChild(clona1 , a2);
				}
			
			window.onload = function(){
			//将北京和红警互换
			//1.
//				var bj = document.getElementById("bj");
//				var clonbj = bj.cloneNode(true);//克隆bj
//				var ul1 = document.getElementById("city"); 
//				
//				var hj = document.getElementById("rl");
//				var clonhj = hj.cloneNode(true);
//				var ul2 = document.getElementById("game");
//
//				ul2.replaceChild(clonbj , hj);
//				ul1.replaceChild(clonhj , bj);
				
			//2.
			fun("bj" , "rl");
				
			}
			
		</script>
	</head>
	<body>
		
		<p>你喜欢哪个城市?</p>
		<ul id="city">
			<li id="bj" name="BeiJing">北京</li>
			<li>上海</li>
			<li>东京</li>
			<li>首尔</li>
		</ul>
		
		<br><br>
		<p>你喜欢哪款单机游戏?</p>
		<ul id="game">
			<li id="rl">红警</li>
			<li>实况</li>
			<li>极品飞车</li>
			<li>魔兽</li>
		<br />
		
	</body>
</html>
